package com.example.data.jpa.dao;

import com.example.data.jpa.entity.User;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author fanhang
 */
public interface UserCustomerOperation {
    /**
     * 第 3 种自定义
     */
    List<User> findCustomerImpl(int age, String remark);


    /**
     * 与片段接口对应的类名中最重要的部分是 Impl 后缀
     */
    @Repository
    record UserCustomerOperationImpl(JdbcTemplate jdbcTemplate) implements UserCustomerOperation {
        @Override
        public List<User> findCustomerImpl(int age, String remark) {
            return jdbcTemplate.queryForList("select * from t_user where age = ? and remark = '?' ", User.class, age, remark);
        }
    }
}
